<?php
class WeixinAction extends Action {
	public function index() {
		import ( 'Weixin', APP_PATH . 'Common', '.php' );
		define ( "TOKEN", "wemall" );
		
		$m = M ( "Weixin" );
		$where["id"] = 1;
		$result = $m->where($where)->select ();
		
		$folder = explode("/", $_SERVER["SCRIPT_NAME"])[1];
		
		$wechatObj = new wechatCallbackapiTest ( $result[0] ['title'], 'http://' . $_SERVER ['HTTP_HOST'] . '/'.$folder.'/Public/Uploads/' . $result[0]['picurl'],  $result[0]['description'], 'http://' . $_SERVER ['HTTP_HOST'] . '/'.$folder.'/app.php?uid=' );
		if (! isset ( $_GET ['echostr'] )) {
			$wechatObj->responseMsg ();
		} else {
			$wechatObj->valid ();
		}
	}
	public function replay() {
		$m = M ( "Weixin" );
		$where["id"] = 1;
		$result = $m->where($where)->select ();
		
		$this->assign("result" , $result[0]);
		$this->display ();
	}
}